package com.ok.runnable;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ok.constant.JmQueue;
import com.ok.constant.WsEventEnum;
import com.ok.event.WsEventManage;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 *监测点实时数据处理
 */
@Slf4j
public class PointRDataRunnable extends AbstractRunable {
    @Override
    public void run() {
        while (this.run) {
            try {
                JSONObject obj= JmQueue.pointRDataBQ.poll(2, TimeUnit.SECONDS);
                if (obj!=null){
                    WsEventManage.notifyWsEvent(WsEventEnum.pointRData.getCode(),null, JSON.toJSONString(obj));
                    //20241227 处理产线监测点实时数据通知
                    WsEventManage.notifyMesDataEvent(WsEventEnum.mesPintRData.getCode(), JSON.toJSONString(obj));
                }
            } catch (Exception e) {
                log.error("监测点实时数据处理异常:", e);
            } catch (Throwable e) {
                log.error("监测点实时数据处理崩溃", e);
                throw e;
            }
        }
    }
}
